package com.JustTest;

import com.alibaba.fastjson.JSON;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

class Solution {
    private static final Integer[][] r1 = new Integer[][]{{0,1,0,0},{0,0,0,1},{1,0,0,0},{0,0,1,0}};
    public int bestRotation(int n) {
        List<Integer[][]> result = new ArrayList<>();
        Integer[][] a = new Integer[n][n];
        test(a, 0, 0, n, result);
        System.out.println("JSON SIZE:" + result.size());
        return 0;
    }

    private void test(Integer[][] a, int m, int n, int size, List<Integer[][]> result) {
        Integer[][] a1 = a.clone();
        for (int i = 0; i < size; i++) {
            a1[m][i] = 0;
        }
        a1[m][n] = 1;
//        if(check(a1,m,n,size)==false){
//            System.out.println("false:"+JSON.toJSONString(a1));
////            return;
//        }else{
//            System.out.println("true:"+JSON.toJSONString(a1));
//        }
        System.out.println(JSON.toJSONString(a1));
        if (n < size - 1) {
            test(a1, m, n + 1, size, result);
        }
        if (m < size - 1) {
            test(a1, m + 1, 0, size, result);
        }
        if (m == size - 1) {
//            if (check(a1,m,n,size)) {
////                result.add(a1);
////                System.out.println("true:"+JSON.toJSONString(a1));
//            }else{
//                result.add(a1);
////                System.out.println("false:"+JSON.toJSONString(a1));
//            }
//            if(a1.equals(r1)){
//                System.out.println(JSON.toJSONString(a1));
                result.add(a1);
//            }
        }
    }
    private Boolean check(Integer[][] a,Integer m,Integer n,Integer size) {
        for(int i=0;i<size;i++){
            for(int j=0;j<size;j++){
                if(a[i][j]!=null&&a[i][j]==1){
                    if((m==i||n==j||Math.abs(m-i)==Math.abs(m-j))&&!(m==i&&n==j)){
                        return false;
                    }
                }
            }
        }
        return true;
    }
}

public class MainClass {
    public static int stringToInteger(String input) {
        return Integer.valueOf(input);
    }

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream("/Users/will/git/knowledge/JustTest/src/main/java/com/JustTest/data.txt")));
        String line;
        line = in.readLine();
        int A = stringToInteger(line);

        int ret = new Solution().bestRotation(A);

        String out = String.valueOf(ret);

        System.out.print(out);
    }
}